home *** CD-ROM | disk | FTP | other *** search
/ El Mac 9 / El Mac 9.iso / Shareware / Applications / MathPad 2.4 / XFuns / XFun kit / util src / entry68K.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-14  |  1.6 KB  |  62 lines  |  [TEXT/CWIE]

  1. /*
  2.    This file contains generic code seg entry points for use by 68K XFuns.
  3.    For convienience, all setting and restoring of A4 is handled here.
  4.  
  5.    All the real work is done elsewhere by the routines:
  6.    
  7.      initialize()
  8.      doevent(theEvent)
  9.      dopredef()
  10.      dofuncall(retval)
  11.    
  12.    This example uses all 4 possible entry points.
  13.    The main() and funcall() entries are required for all XFuns.
  14.    The predef() is used only if your XFun needs to reset something each time
  15.    the doc is reevaluated. If it isn't used just pass a NULL to AddXfun().
  16.    The handler() is used if your XFun needs access to events. If your XFun
  17.    creates a window it must install a valid handler.  If no handler is needed
  18.    then don't call InstallEventHandler().
  19. */
  20.  
  21. #include "A4globs.h"        /* magic A4 macros */
  22. #include "callbackg.h"        /* use "global" version of callbacks */
  23. #include "XFundef.h"        /* prototypes for routines specific to this XFun */
  24.  
  25. funptr callback;            /* global used by all callback routines (callbackg.c) */
  26.  
  27. static short handler(EventRecord *theEvent,funptr callbackptr)
  28. {
  29.    int done;
  30.    SetUpA4();
  31.    done = doevent(theEvent);
  32.    RestoreA4();
  33.    return(done);
  34. }
  35.  
  36. static short predef(funptr callbackptr)
  37. {
  38.    SetUpA4();
  39.    dopredef();
  40.    RestoreA4();
  41.    return(0);
  42. }
  43.  
  44. static short funcall(double *retval,funptr callbackptr)
  45. {
  46.    int ok;
  47.    SetUpA4();
  48.    ok = dofuncall(retval);
  49.    RestoreA4();
  50.    return(ok);
  51. }
  52.  
  53. void main(funptr callbackptr)
  54. {
  55.     EnterResource();
  56.     callback = callbackptr;    /* save callback in global for callbackg routines */
  57.     AddXfun(FUNNAME,FUNPARMS,&funcall,&predef);
  58.     InstallEventHandler(&handler);
  59.     initialize();
  60.     RestoreA4();
  61. }
  62.